var testRunner = new TestRunner();

var formSuite = new TestSuite("Form Object Unit Tests");
formSuite.add(new TestCase("Parsing Document For Forms", test_form_parseForms));
testRunner.add(formSuite);

function loadChromeUrl(str_Filename) {
	var url = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIStandardURL);
	url.init(1, 0, str_Filename, null, null);

	var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
	var chan = ios.newChannelFromURI(url);

	var sin = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
	sin.init(chan.open());
	var text = sin.read(sin.available());
	sin.close();
	return text;
}

function test_form_parseForms() {
	var docParser = new DOMParser();
	assertNotNull("testing setup","");
	assertNotNull("docParser not null",docParser);
//	var xmlStr = loadChromeUrl("chrome://accessext/content/testdata/form.html");
	var Win = window.open("chrome://accessext/content/testdata/form.html","testWindow", "chrome, centerscreen, resizable, width=100, height=100");
	try {
		assertFalse("Window not closed",Win.closed);
		Win.close();
		assertTrue("Window closed",Win.closed);
	} catch (e) {
	
	}
	
//	Win.close();
	
/*	assertNotNull("data loaded",xmlStr);
	assertTrue("form.html has text",xmlStr.length > 0);
	var doc = docParser.parseFromString(xmlStr,'text/xml');
	assertNotNull("doc not null",doc);


//	var tempWindow = window.open("chrome://accessext/content/testdata/form.html","accessext-unit-test-temp-window","dialog=yes, resizable=yes");
//	doc = tempWindow.content.document;
	var formObjs = parseAndLoadFormObjects(doc);
		
	assertNotNull("parseAndLoadFormObjects returns",formObjs);
	assertEquals("Find 3 forms",3,formObjs.length);
	assertEquals("Get correct ID on form 1","form1",formObjs[0].node.id);
	assertEquals("Get correct ID on form 2","form2",formObjs[1].node.id);
	assertEquals("Get correct ID on form 3","form3",formObjs[2].node.id);*/
}